package com.wang.designpattern.memento;

public class Client {

    public static void main(String[] args) {
        Originator originator = new Originator();
        Caretaker caretaker = new Caretaker();

        originator.setState("状态1 100");
        caretaker.add(originator.saveStateMemento());

        originator.setState("状态2 80");
        caretaker.add(originator.saveStateMemento());

        originator.setState("状态2 50");
        caretaker.add(originator.saveStateMemento());

        System.out.println("当前状态是：" + originator.getState());
        Memento memento = caretaker.get(0);
        originator.getStateMemento(memento);
        System.out.println("恢复到状态1");
        System.out.println("当前状态是：" + originator.getState());
    }
}
